package com.neelsys.visualisation.service.adapter;

import java.util.Set;

import com.neelsys.visualisation.domain.BaseNodeEntity;
import com.neelsys.visualisation.domain.EntranceTest;

public class NextLevelEntranceTestAdapter {

	private long level;

	private MajorCombAdapter combAdapter;

	public NextLevelEntranceTestAdapter(MajorCombAdapter combAdapter, long level) {
		this.combAdapter = combAdapter;
		this.level = level;
	}

	public void adapt(Set<EntranceTest> tests,
			BaseNodeEntity fromNode) {

		for (EntranceTest entranceTest : tests) {

			combAdapter.addNodeToGraph(combAdapter.jsonGraph, combAdapter
					.createNewNode(entranceTest.getEntranceTestDetails(), "E",
							entranceTest.getNodeId(), level));

			combAdapter.createRelationShip(fromNode, entranceTest,
					combAdapter.jsonGraph);

			NextLevelCourseAdapter nextLvlCourse = new NextLevelCourseAdapter(
					combAdapter, level + 1);
			combAdapter.template.fetch(entranceTest.getNextCourses());

			nextLvlCourse.adapt(entranceTest.getNextCourses(),
					entranceTest);

		}

	}

}
